package cn.hema.mapper;

import cn.hema.po.Borrower;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BorrowerMapper {

    @Select("SELECT id, name, phone, createdAt, borrowLimit FROM borrowers WHERE id = #{id}")
    Borrower getBorrowerById(Long id);

    @Select("SELECT id, name, phone, createdAt, borrowLimit FROM borrowers")
    List<Borrower> getAllBorrowers();

    @Insert("INSERT INTO borrowers (name, phone) VALUES (#{name}, #{phone})")
    void addBorrower(Borrower borrower);

    @Update("UPDATE borrowers SET name = #{name}, phone = #{phone}, borrowLimit = #{borrowLimit} " +
            "WHERE id = #{id}")
    void updateBorrower(Borrower borrower);

    @Delete("DELETE FROM borrowers WHERE id = #{id}")
    void deleteBorrower(Long id);
}
